import asyncio
from fastapi import FastAPI
from fastapi.templating import Jinja2Templates
import uvicorn
from fastapi.staticfiles import StaticFiles
from src.apps.app01 import app01

from tortoise.contrib.fastapi import register_tortoise
from settings import TORTOISE_ORM
from api.MedicineInfo import student_api

app = FastAPI()
app.mount("/static", StaticFiles(directory="statics"))
# app.include_router(student_api, prefix="/student", tags=["选课系统的学生接口"])
app.include_router(student_api, tags=["选课系统的学生接口"])

register_tortoise(
    app=app,
    config=TORTOISE_ORM,
    # generate_schemas=True,
)


async def main():
    config = uvicorn.Config("main:app", host="192.168.0.166", port=5000, log_level="info", reload=True,
                            workers=1)
    server = uvicorn.Server(config)
    await server.serve()


if __name__ == '__main__':
    asyncio.run(main())
